// Copyright(c) Sonosemi Medical Ltd. Embedded Software Team.
// Author: Zhang Yisong(zhangyisong@sonosemi.com)

#pragma once
#include "active/active_config.hpp"
#include "active/active_errors.hpp"
#include "active/active_event.hpp"
#include "active/active_states.hpp"
#include "boost/mp11.hpp"
#include "boost/sml.hpp"
#include "etl/queue.h"
#include "etl/singleton.h"
#include "internal/active_active.hpp"
#include "internal/active_cib_config.hpp"
#include "internal/active_policy.hpp"
#include "internal/active_task.hpp"
#include "internal/active_thread_safe.hpp"
#include "internal/concepts/active_active.hpp"
#include <variant>
namespace active {
// using namespace boost::sml;

template <concepts::ActiveConfiguable... TActive>
[[maybe_unused]] inline static auto Initialize(TActive...) {
  using namespace boost::mp11;
  using ActiveTuple = std::tuple<TActive...>;
  using SmTuple = std::tuple<typename TActive::SmConfigType...>;
  using SmTupleUnique = boost::mp11::mp_unique<SmTuple>;
  static_assert(mp_size<SmTuple>::value == mp_size<SmTupleUnique>::value,
                "Duplicated state machines are not allowed!");
  std::apply(
      [](auto... args) {
        (decltype(args)::Init(), ...);
        static cib::nexus<internal::Project<decltype(args)...>> n;
        n.init();
        (decltype(args)::InitEvents(), ...);
        MakeScheduler<typename decltype(args)::ProcessingTask...>();
      },
      ActiveTuple{});
}
} // namespace active

namespace atv {
using namespace active;
}